/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.financial.entity.incomeexpenditure;

import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.ar.entity.Tar;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.fixedexpense.FixedExpense;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import com.jeesite.modules.payment.entity.Tap;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;

/**
 * 收支明细单Entity
 *
 * @author LV
 * @version 2021-03-04
 */
@Table(name = "t_income_expenditure", alias = "a", columns = {
        @Column(name = "income_expenditure_id", attrName = "incomeExpenditureId", label = "收支明细单ID", isPK = true),
        @Column(name = "income_expenditure_code", attrName = "incomeExpenditureCode", label = "单据编号", queryType = QueryType.LIKE),
        @Column(name = "service_order_id", attrName = "serviceOrderId", label = "服务订单"),
        @Column(name = "customer_id", attrName = "customerId", label = "客户名称"),
        @Column(name = "supplier_id", attrName = "supplierId", label = "供应商名称"),
        @Column(name = "scanner_type", attrName = "scannerType", label = "录入类型"),
        @Column(name = "currency", attrName = "currency", label = "外币币种", isQuery = false),
        @Column(name = "foreign_businessmen_id", attrName = "foreignBusinessmenId", label = "外商名称"),
        @Column(name = "accounting_receivable", attrName = "accountingReceivable", label = "应收单编号"),
        @Column(name = "accounting_payable", attrName = "accountingPayable", label = "应付单编号"),
        @Column(name = "actual_exchange_rate", attrName = "actualExchangeRate", label = "实际汇率", isQuery = false),
        @Column(name = "expense_item", attrName = "expenseItem", label = "费用项目"),
        @Column(name = "remarks", attrName = "remarks", label = "备注信息", isQuery = false),
        @Column(name = "income_amount", attrName = "incomeAmount", label = "收入金额", isQuery = false),
        @Column(name = "expenditure_amount", attrName = "expenditureAmount", label = "支出金额", isQuery = false),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间"),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "c",
                on = "c.customer_id = a.customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplier", alias = "d",
                on = "d.supplier_id = a.supplier_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "forSupplier", alias = "e",
                on = "e.supplier_id = a.foreign_businessmen_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Tap.class, attrName = "tap", alias = "f",
                on = "f.ap_id = a.accounting_payable",
                columns = {
                        @Column(name = "ap_id", label = "应付单ID", isPK = true),
                        @Column(name = "ap_code", label = "应付单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Tar.class, attrName = "tar", alias = "g",
                on = "g.ar_id = a.accounting_receivable",
                columns = {
                        @Column(name = "ar_id", label = "应收单ID", isPK = true),
                        @Column(name = "ar_code", label = "应收单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "s",
                on = "s.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = FixedExpense.class, attrName = "fixedExpense", alias = "h",
                on = "h.fixed_expense_id = a.expense_item",
                columns = {
                        @Column(name = "fixed_expense_id", label = "项目编号", isPK = true),
                        @Column(name = "fixed_expense_name", label = "项目名称"),
                }),
}, orderBy = "a.update_date DESC"
)
public class IncomeExpenditure extends DataEntity<IncomeExpenditure> {

    private static final long serialVersionUID = 1L;
    private String incomeExpenditureId;        // 收支明细单ID
    private String incomeExpenditureCode;        // 单据编号
    private String serviceOrderId;        // 服务订单
    private ServiceOrder serviceOrder;        // 服务订单
    private String customerId;        // 客户名称
    private Customer customer;
    private String supplierId;        // 供应商名称
    private Supplier supplier;
    private String currency;        // 外币币种
    private String scannerType;        // 录入类型
    private String foreignBusinessmenId;        // 外商名称
    private Supplier forSupplier;
    private String accountingReceivable;        // 应收单编号
    private String accountingPayable;        // 应付单编号
    private String actualExchangeRate;        // 实际汇率
    private String expenseItem;        // 费用项目
    private Double incomeAmount;        // 收入金额
    private Double expenditureAmount;        // 支出金额
    private IncomeExpenditureDetail incomeExpenditureDetail;
    private List<IncomeExpenditureDetail> incomeExpenditureDetailList = ListUtils.newArrayList();        // 子表列表
    private Tap tap;
    private Tar tar;
    private FixedExpense fixedExpense;
    private String userFlag;

    public IncomeExpenditure() {
        this(null);
    }

    public IncomeExpenditure(String id) {
        super(id);
    }

    public String getIncomeExpenditureId() {
        return incomeExpenditureId;
    }

    public void setIncomeExpenditureId(String incomeExpenditureId) {
        this.incomeExpenditureId = incomeExpenditureId;
    }

    @Length(min = 0, max = 100, message = "单据编号长度不能超过 100 个字符")
    public String getIncomeExpenditureCode() {
        return incomeExpenditureCode;
    }

    public void setIncomeExpenditureCode(String incomeExpenditureCode) {
        this.incomeExpenditureCode = incomeExpenditureCode;
    }

    @Length(min = 0, max = 64, message = "服务订单长度不能超过 64 个字符")
    public String getServiceOrderId() {
        return serviceOrderId;
    }

    public void setServiceOrderId(String serviceOrderId) {
        this.serviceOrderId = serviceOrderId;
    }

    @Length(min = 0, max = 64, message = "客户名称长度不能超过 64 个字符")
    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    @Length(min = 0, max = 64, message = "供应商名称长度不能超过 64 个字符")
    public String getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(String supplierId) {
        this.supplierId = supplierId;
    }

    @Length(min = 0, max = 2, message = "外币币种长度不能超过 2 个字符")
    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    @Length(min = 0, max = 64, message = "外商名称长度不能超过 64 个字符")
    public String getForeignBusinessmenId() {
        return foreignBusinessmenId;
    }

    public void setForeignBusinessmenId(String foreignBusinessmenId) {
        this.foreignBusinessmenId = foreignBusinessmenId;
    }

    @Length(min = 0, max = 100, message = "应收单编号长度不能超过 100 个字符")
    public String getAccountingReceivable() {
        return accountingReceivable;
    }

    public void setAccountingReceivable(String accountingReceivable) {
        this.accountingReceivable = accountingReceivable;
    }

    @Length(min = 0, max = 100, message = "应付单编号长度不能超过 100 个字符")
    public String getAccountingPayable() {
        return accountingPayable;
    }

    public void setAccountingPayable(String accountingPayable) {
        this.accountingPayable = accountingPayable;
    }

    @Length(min = 0, max = 10, message = "实际汇率长度不能超过 10 个字符")
    public String getActualExchangeRate() {
        return actualExchangeRate;
    }

    public void setActualExchangeRate(String actualExchangeRate) {
        this.actualExchangeRate = actualExchangeRate;
    }

    @NotBlank(message = "费用项目不能为空")
    @Length(min = 0, max = 64, message = "费用项目长度不能超过 64 个字符")
    public String getExpenseItem() {
        return expenseItem;
    }

    public void setExpenseItem(String expenseItem) {
        this.expenseItem = expenseItem;
    }

    public Double getIncomeAmount() {
        return incomeAmount;
    }

    public void setIncomeAmount(Double incomeAmount) {
        this.incomeAmount = incomeAmount;
    }

    public Double getExpenditureAmount() {
        return expenditureAmount;
    }

    public void setExpenditureAmount(Double expenditureAmount) {
        this.expenditureAmount = expenditureAmount;
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public Date getUpdateDate_gte() {
        return sqlMap.getWhere().getValue("update_date", QueryType.GTE);
    }

    public void setUpdateDate_gte(Date updateDate) {
        sqlMap.getWhere().and("update_date", QueryType.GTE, updateDate);
    }

    public Date getUpdateDate_lte() {
        return sqlMap.getWhere().getValue("update_date", QueryType.LTE);
    }

    public void setUpdateDate_lte(Date updateDate) {
        sqlMap.getWhere().and("update_date", QueryType.LTE, updateDate);
    }

    public List<IncomeExpenditureDetail> getIncomeExpenditureDetailList() {
        return incomeExpenditureDetailList;
    }

    public void setIncomeExpenditureDetailList(List<IncomeExpenditureDetail> incomeExpenditureDetailList) {
        this.incomeExpenditureDetailList = incomeExpenditureDetailList;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Supplier getForSupplier() {
        return forSupplier;
    }

    public void setForSupplier(Supplier forSupplier) {
        this.forSupplier = forSupplier;
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public IncomeExpenditureDetail getIncomeExpenditureDetail() {
        return incomeExpenditureDetail;
    }

    public void setIncomeExpenditureDetail(IncomeExpenditureDetail incomeExpenditureDetail) {
        this.incomeExpenditureDetail = incomeExpenditureDetail;
    }

    public Tap getTap() {
        return tap;
    }

    public void setTap(Tap tap) {
        this.tap = tap;
    }

    public Tar getTar() {
        return tar;
    }

    public void setTar(Tar tar) {
        this.tar = tar;
    }

    public String getScannerType() {
        return scannerType;
    }

    public void setScannerType(String scannerType) {
        this.scannerType = scannerType;
    }

    public FixedExpense getFixedExpense() {
        return fixedExpense;
    }

    public void setFixedExpense(FixedExpense fixedExpense) {
        this.fixedExpense = fixedExpense;
    }

    public String getUserFlag() {
        return userFlag;
    }

    public void setUserFlag(String userFlag) {
        this.userFlag = userFlag;
    }
}
